package kits.ftp;

import java.io.IOException;

import it.sauronsoftware.ftp4j.FTPClient;
import it.sauronsoftware.ftp4j.FTPException;
import it.sauronsoftware.ftp4j.FTPIllegalReplyException;
import lombok.Getter;
import lombok.Setter;
/**
 * 如果上传不了,需要关闭防火墙
 * @ClassName: FtpKit  
 * @Description: TODO 
 * @author: npc QQ:568081714
 * @date:2017年3月9日 上午12:56:24
 */
public class FtpKit {
	@Getter
	@Setter
	private FtpConfig ftpEntity;
	@Getter
	private FTPClient client;

	public FtpKit(FtpConfig ftpEntity) {
		// 创建客户端
		client = new FTPClient();
		// 不指定端口，则使用默认端口21
		try {
			client.setType(FTPClient.TYPE_BINARY);
			client.setCharset("UTF-8");
			client.connect(ftpEntity.getIp(), ftpEntity.getPort());
			
			// 用户登录
			client.login(ftpEntity.getUserName(), ftpEntity.getPassword());
			System.out.println(client);
		} catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) {
			e.printStackTrace();
		}
	}

	
}
